import getdata from '../models/getdata';


class RenderRecent{
    constructor(){

    }
    async render(type){
        type = type == undefined ?'monday' :type;
        let listindex = null;
        switch(type){
            case 'monday'   : listindex = (await getdata.getrecent()).suggest;break;
            case 'tuesday'  : listindex = (await getdata.getrelax()).suggest;break;
            case 'wednesday': listindex = (await getdata.getcomic()).suggest;break;
            case 'thursday' : listindex = (await getdata.getmusic()).suggest;break;
            case 'friday'   : listindex = (await getdata.getopera()).suggest;break;
            case 'saturday' : listindex = (await getdata.getoversea()).suggest;break;
            case 'sunday'     : listindex = (await getdata.getphysical()).suggest;break;
            default         : "";
        }
        
        //console.log(listindex);
        // console.log(recentTpl);
        let html = ""
        $.each(listindex,(index,item) => {

            //console.log(this)
            html +=`<li>
            <div class="show-img" style="background-image: url(${item.verticalPic})"></div>  
            <span>
                    ${item.projectName}
            </span>
            <p>
                    ￥${item.price}起
            </p>
        </li>`
        })
        // let html = template.render(recentTpl,{
        //     listindex
        // })
        
        $('.show-work ul').html(html);
    }
}


export default new RenderRecent();